package com.cdp.zwy.background_manager_back.service;

import com.cdp.zwy.background_manager_back.domain.Admin;
import com.cdp.zwy.background_manager_back.mapper.AdminMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Administrator
 * @version 1.0
 * @description: TODO
 * @date 2025/3/27 16:25
 */
@Service
public class AdminService {
    @Resource
    private AdminMapper adminMapper;
    public List<Admin> selectAll(Admin admin){
        return adminMapper.selectAll(admin);

    }
    public Admin selectById(Integer id){
        return adminMapper.selectById(id);
    }
    public List<Admin> selectList(Admin admin){
        System.out.println(admin);
        return null;
    }

    /**
     * 分页查询
     * @param pageNum
     * @param pageSize
     * @return
     */
    public PageInfo<Admin> selectPage(Admin admin,Integer pageNum, Integer pageSize){
        PageHelper.startPage(pageNum,pageSize);
        List<Admin> list = adminMapper.selectAll(admin);
        return PageInfo.of(list);
    }

    public int add(Admin admin){
        return adminMapper.insert(admin);
    }

    public int update(Admin admin) {
        return adminMapper.update(admin);
    }

    public int delete(Integer id) {
        return adminMapper.delete(id);
    }
}
